package com.huabo.system.service.impl;

import com.hbfk.util.PageInfo;
import com.huabo.system.mysql.entity.TblMonitorRuleMySql;
import com.huabo.system.mysql.mapper.TblMonitorRuleMySqlMapper;
import com.huabo.system.oracle.entity.TblMonitorRule;
import com.huabo.system.oracle.mapper.TblMonitorRuleMapper;
import com.huabo.system.service.TblMonitorRuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Service
public class TblMonitorRuleServiceImpl implements TblMonitorRuleService {

    @Resource
    private TblMonitorRuleMapper tblMonitorRuleMapper;

    @Resource
    private TblMonitorRuleMySqlMapper tblMonitorRuleMySqlMapper;

    @Override
    public Map<String, Object> findTblMonitorRuleByUser(BigDecimal staffid, PageInfo<TblMonitorRule> pageInfo) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        pageInfo.setTlist(this.tblMonitorRuleMapper.findTblMonitorRuleByUser(pageInfo, staffid));
        pageInfo.setTotalRecord(this.tblMonitorRuleMapper.findTblMonitorRuleByUserCount(staffid));
        resultMap.put("code", "1");
        resultMap.put("msg", "访问接口成功");
        resultMap.put("data", pageInfo);
        return resultMap;
    }

    @Override
    public Map<String, Object> findTblMonitorRuleByMySqlUser(BigDecimal staffid, PageInfo<TblMonitorRuleMySql> pageInfo) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        pageInfo.setTlist(this.tblMonitorRuleMySqlMapper.findTblMonitorRuleByUser(pageInfo, staffid));
        pageInfo.setTotalRecord(this.tblMonitorRuleMySqlMapper.findTblMonitorRuleByUserCount(staffid));
        resultMap.put("code", "1");
        resultMap.put("msg", "访问接口成功");
        resultMap.put("data", pageInfo);
        return resultMap;
    }

    @Override
    public TblMonitorRule findOne(BigDecimal ruleid) {
        return tblMonitorRuleMapper.findRuleid(ruleid);
    }

    @Override
    public TblMonitorRuleMySql findMySqlOne(BigDecimal ruleid) {
        return tblMonitorRuleMySqlMapper.findRuleid(ruleid);
    }

    @Override
    public void findAll(String solutionid, PageInfo<TblMonitorRule> pageInfo) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        pageInfo.setTlist(this.tblMonitorRuleMapper.findAll(solutionid, pageInfo));
        pageInfo.setTotalRecord(this.tblMonitorRuleMapper.findAllCount(solutionid));
        resultMap.put("code", "1");
        resultMap.put("msg", "访问接口成功");
        resultMap.put("data", pageInfo);
    }

    @Override
    public void findAllMySql(String solutionid, PageInfo<TblMonitorRuleMySql> pageInfo1) {
        Map<String, Object> resultMap = new HashMap<String, Object>(0);
        pageInfo1.setTlist(this.tblMonitorRuleMySqlMapper.findAll(solutionid, pageInfo1));
        pageInfo1.setTotalRecord(this.tblMonitorRuleMySqlMapper.findAllCount(solutionid));
        resultMap.put("code", "1");
        resultMap.put("msg", "访问接口成功");
        resultMap.put("data", pageInfo1);
    }
}
